package com.zzt.zt_colorpicker;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;

import com.zzt.zt_colorpicker.v1.ColorPickerDialog;
import com.zzt.zt_colorpicker.v2.V2Act;

public class MainActivity extends AppCompatActivity {
    /**
     * 选择的颜色
     */
    private int mColor = 0xFFFFFF;

    private View view_show;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        initView();

    }

    private void initView() {
        view_show = findViewById(R.id.view_show);
        findViewById(R.id.button1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                new ColorPickerDialog.Builder(MainActivity.this, mColor)
                        .setHexValueEnabled(true)//是否显示颜色值
                        //设置点击应用颜色的事件监听
                        .setOnColorPickedListener(new ColorPickerDialog.OnColorPickedListener() {
                            @Override
                            public void onColorPicked(int color) {
                                mColor = color;
                                view_show.setBackgroundColor(mColor);
                            }
                        })
                        .build()
                        .show();//展示
            }
        });

        findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                V2Act.start(v.getContext());
            }
        });

    }

}